﻿
// <copyright file="Program.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The program.
// </summary>

using System.Data.SqlClient;
using SubhadraSolutions.Sharp.Utils.Data.Dynamic;
using SubhadraSolutions.Sharp.Utils.Data.SqlServer;
using System.ComponentModel.DataAnnotations;
using System.Drawing.Text;
using System.Linq;
using SubhadraSolutions.Sharp.Utils.Collections.Generic;
using SubhadraSolutions.Sharp.Utils.Data.Helpers;

namespace SubhadraSolutions.Sharp.Utils.TestApplication
{
    using System;
    using System.Collections.Generic;

    public class Employee007
    {
        [Key]
        public string Id { get; set; }
        public string Name { get; set; }
        public string DepartmentName { get; set; }
    }

    /// <summary>
    /// The program.
    /// </summary>
    internal static class Program
    {
        #region Methods

        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            //SubhadraSolutions.Sharp.Utils.IO.FindReplaceHelper.ReplaceInDirectoriesAndFiles(@"C:\Eurofins.Gravity", "DDBS.LIMS", "Gravity", true, true, true, "*.cs", "*.csproj", "*.asmx", "*.config", "*.resx", "*.sql", "*.aspx", "*.sln", "*.user", "*.testsettings", "*.vspscc");
            //SubhadraSolutions.Sharp.Utils.IO.FindReplaceHelper.ReplaceInDirectoriesAndFiles(@"C:\Eurofins.Gravity", "DDBS.LIMS", "Gravity", false, true, false, "*.suo", "*.dll");

            //string directory = @"C:\TFS\Sprint6\Source\ModuleStubs";
            //string oldString = @"SampleManagement";
            //string newString = @"NameOfTheModule";
            //SubhadraSolutions.Sharp.Utils.IO.FindReplaceHelper.ReplaceInDirectoriesAndFiles(directory, oldString, newString, true, true, true, "*.cs", "*.csproj", "*.asmx", "*.config", "*.resx", "*.sql", "*.aspx", "*.sln", "*.user", "*.testsettings", "*.vspscc");
            //SubhadraSolutions.Sharp.Utils.IO.FindReplaceHelper.ReplaceInDirectoriesAndFiles(directory, oldString, newString, false, true, false, "*.suo", "*.dll");

            
            ////SubhadraSolutions.Sharp.Utils.IO.FindReplaceHelper.ReplaceInDirectoriesAndFiles(@"C:\Eurofins.Gravity", @"..\Output\", @"bin\debug\", false, false, true, "*.csproj");
          
            //const string constr = "Data Source=.;Initial Catalog=B;Integrated Security=True";
            //using (var connection = new SqlConnection(constr))
            //{
            //    connection.Open();

            //    //var command = connection.CreateCommand();
            //    //command.CommandText = DDLHelper.GenerateCreateTableScriptForDto<Employee007>("Employee007", false);
            //    //command.ExecuteNonQuery();
            //    var enumerable = GetEmployees();
            //    var dt = enumerable.ExportAsDataTable();
            //    var newList = dt.ExportAsListOfObjects<Employee007>(true);

            //    var reader = DataReaderHelper.GetDataFromCharSeparatedFile(@"D:\exp.txt", '\t');
            //    var emps = reader.ConvertDataReaderToObjects<Employee007>();

            //    //BulkCopier.Instance.DoBulkCopy(reader, connection,"Employee007");
            //    //DynamicDAO<Employee007>.Insert(emp, connection);

            //}

            
            ////SubhadraSolutions.Sharp.Utils.IO.FindReplaceHelper.RenameFiles(@"D:\Personal\MC1\All Reusables\Reusables\Eurofins.IT.Reusables.Windows.WebSpider","Eurofins.IT.Reusables.Windows","SubhadraSolutions.Sharp",false,"*.cs", "*.csproj", "*.asmx", "*.config", "*.resx", "*.sql", "*.aspx", "*.sln");
            //IList<DummyEmployee> list = new List<DummyEmployee>();
            //for (int i = 0; i < 10; i++)
            //{
            //    list.Add(new DummyEmployee());
            //}
            //list = new SafeListDecorator<DummyEmployee>(list);
            //var view = CollectionViewSource.GetDefaultView(list);
            //foreach (var v in view)
            //{
            //    //var obj = v;
            //}
            //ListNotifyCollectionChangedAdapterTestsLauncher.Launch();
            //FileReadingTestLauncher.Test();
            //NotifyPropertyChangedLauncher.Launch();
            ListNotifyCollectionChangedAdapterTestsLauncher.Launch();
        }

        private static IEnumerable<Employee007> GetEmployees()
        {
            for (int i = 0; i < 1000; i++)
            {
                var emp = new Employee007();
                if (i%10 != 0)
                {
                    emp.Id = i.ToString();
                    emp.Name = "Subrah" + i.ToString();
                    emp.DepartmentName = "IT";
                }
                yield return emp;
            }
        }

        #endregion Methods
    }
}